<template>
  <div class="main" span="24">
   <div class="head"><img src="../../../static/images/banner1.jpg"></div>
     <div class="weui-cells__title">个人信息</div>
     <div class="weui-cells weui-cells_form">
       <div class="weui-cell">
         <div class="weui-cell__hd">
        <label class="weui-label">账号</label>
       </div>
      <div class="weui-cell__bd">
      <input class="weui-input" v-model="UNIFIED_ACCT_NUMBER" disabled="disabled" > 
      </div>
      </div> 
      <div class="weui-cell">
         <div class="weui-cell__hd">
        <label class="weui-label">绑定手机</label>
       </div>
      <div class="weui-cell__bd">
      <input class="weui-input" v-model="PHONE" disabled="disabled">
      </div>
      </div>
    </div>
         <div class="weui-cells__title">企业认证信息</div>
  <div class="weui-cells weui-cells_form">
       <div class="weui-cell"  v-if="IF_SHOW">
         <div class="weui-cell__hd">
        <label class="weui-label">企业名称</label>
       </div>
      <div class="weui-cell__bd">
      <input class="weui-input" v-model="COMPANY_NAME" disabled="disabled"> 
      </div>
      </div> 
      <div class="weui-cell">
         <div class="weui-cell__hd">
        <label class="weui-label">企业认证状态</label>
       </div>
      <div class="weui-cell__bd">  
      <input class="weui-input" v-model="STATE_MESSAGE" disabled="disabled">
      </div>
      <div class="weui-cell__bd">
        <i-tag v-if="STATE"
    class="i-tags" style="margin-left:20px;"
    name="标签一" 
    color="green" type="border" @click="handleclick(TAG_MESSAGE)">
   {{TAG_MESSAGE}}
       </i-tag>
      </div>
      </div> 
       <div class="weui-cell" v-if="IF_SHOW"> 
         <div class="weui-cell__hd">
        <label class="weui-label">企业证件类型</label>
       </div>
      <div class="weui-cell__bd">
      <input class="weui-input" disabled="disabled" v-model="COMPANY_CERT_TYPE">
      </div>
      </div> 
         <div class="weui-cell" v-if="IF_SHOW"> 
         <div class="weui-cell__hd">
        <label class="weui-label">公司证件号码</label>
       </div>
      <div class="weui-cell__bd">
      <input class="weui-input" disabled="disabled" v-model="COMPANY_CERT_NUM">
      </div>
      </div> 
         <div class="weui-cell" v-if="IF_SHOW"> 
         <div class="weui-cell__hd">
        <label class="weui-label">公司地址</label>
       </div>
      <div class="weui-cell__bd">
      <input class="weui-input" disabled="disabled" v-model="COMPANY_ADDR">
      </div>
      </div> 
         <div class="weui-cell" v-if="IF_SHOW"> 
         <div class="weui-cell__hd">
        <label class="weui-label">经办人姓名</label>
       </div>
      <div class="weui-cell__bd">
      <input class="weui-input" disabled="disabled" v-model="ATTN_NAME">
      </div>
      </div> 
         <div class="weui-cell" v-if="IF_SHOW"> 
         <div class="weui-cell__hd">
        <label class="weui-label">经办人证件类型</label>
       </div>
      <div class="weui-cell__bd">
      <input class="weui-input" disabled="disabled" v-model="ATTN_CERT_TYPE">
      </div>
      </div> 
         <div class="weui-cell" v-if="IF_SHOW"> 
         <div class="weui-cell__hd">
        <label class="weui-label">经办人证件号码</label>
       </div>
      <div class="weui-cell__bd">
      <input class="weui-input" disabled="disabled" v-model="ATTN_CERT_NUM">
      </div>
      </div> 
         <div class="weui-cell" v-if="IF_SHOW"> 
         <div class="weui-cell__hd">
        <label class="weui-label">经办人证件地址</label>
       </div>
      <div class="weui-cell__bd">
      <input class="weui-input" disabled="disabled" v-model="ATTN_CERT_ADDR">
      </div>
      </div> 
         <div class="weui-cell" v-if="IF_SHOW"> 
         <div class="weui-cell__hd">
        <label class="weui-label">企业证件类型</label>
       </div>
      <div class="weui-cell__bd">
      <input class="weui-input" disabled="disabled" v-model="UNIFIED_ACCT_ID">
      </div>
      </div> 
         <div class="weui-cell" v-if="IF_SHOW"> 
         <div class="weui-cell__hd">
        <label class="weui-label">经办人电话</label>
       </div>
      <div class="weui-cell__bd">
      <input class="weui-input" disabled="disabled" v-model="ATTN_PHONE">
      </div>
      </div> 


         <div class="weui-cell" v-if="IF_SHOW"> 
         <div class="weui-cell__hd">
        <label class="weui-label">营业执照</label>
       </div>
      <div class="weui-cell__bd">
     <img :src="COMPANY_PIC" class="img">
      </div>
      </div> 
      <div class="weui-cell" v-if="IF_SHOW"> 
         <div class="weui-cell__hd">
        <label class="weui-label">经办人证件</label>
       </div>
      <div class="weui-cell__bd">
       <img :src="ATTN_CERT_PIC" class="img">
      </div>
      </div> 
      
      <div class="weui-cell" v-if="IF_SHOW"> 
         <div class="weui-cell__hd">
        <label class="weui-label">委托书</label>
       </div>
      <div class="weui-cell__bd">
       <img :src="AUTHORIZE_PIC" class="img">
      </div>
      </div> 


    </div>
  <i-button type="success" shape="circle" @click="loginout()">退出登录</i-button>
     
          
    
  </div> 
</template>

<script>
import card from '@/components/card'
import 'mpvue-weui/src/style/weui.css';
import mpSearchbar from 'mpvue-weui/src/searchbar'
import {postRequest} from '@/utils/http'
import { async } from 'q';
export default {
  data () {
    return {
      motto: 'Hello miniprograme',
      userInfo: {
        nickName: 'mpvue',
        avatarUrl: 'http://mpvue.com/assets/logo.png'
      },
        COMPANY_NAME: "",//企业名称
        PHONE: "",//绑定手机
        UNIFIED_ACCT_NUMBER:"",
        COMPANY_CERT_TYPE:"",//企业证件类型
        COMPANY_CERT_NUM:'',//公司证件号码
        COMPANY_ADDR:'',//公司地址
        ATTN_NAME:'',//经办人姓名
        ATTN_CERT_TYPE:'',//经办人证件类型
        ATTN_CERT_NUM :'',// 经办人证件号码
        ATTN_CERT_ADDR:"",//经办人证件地址
        UNIFIED_ACCT_ID:'',//企业证件类型
        ATTN_PHONE:'',//经办人电话
        COMPANY_PIC:'',//营业执照
        ATTN_CERT_PIC:'',//经办人证件照片
        AUTHORIZE_PIC:'',//委托书照片
        STATE:'',//可跳转到填写信息页面
        STATE_MESSAGE:"",//企业认证状态信息
        IF_SHOW:false,//显示认证信息,
        TAG_MESSAGE:'',
        ACT_TYPE:'',//修改or新增认证
      imageArray:[
        {"index":1,"url":"http://mpvue.com/assets/logo.png","name":"引导认证"},
        {"index":2,"url":"http://mpvue.com/assets/logo.png","name":"引导认证"},
        {"index":3,"url":"http://mpvue.com/assets/logo.png","name":"引导认证"}
      ]
    }
  },

  components: {
    card,
    mpSearchbar
  },

  methods: {
    async queryCompanyInfo(){
       wx.showLoading({
        title: '认证状态查询中',
        })
     let params =
         {
                'UNIFIED_ACCT_ID':this.UNIFIED_ACCT_ID,
                'UNIFIED_ACCT_NUMBER':this.UNIFIED_ACCT_NUMBER,
                'PHONE':this.PHONE
      };
      const info = await postRequest('/queryCompanyInfo/v0',params);
      const result = info.UNI_BSS_BODY;
      console.log(result);
      // result.RSP.CODE = '0003';
      wx.setStorageSync("CompanyInfo",result.RSP.DATA);
       if(result.RSP.CODE == 'A' || result.RSP.CODE == '0003'){
        this.STATE = true;
        this.TAG_MESSAGE = "立即认证";
        this.STATE_MESSAGE = "未提交认证信息"
        }
        else{
          this.IF_SHOW = true;
          this.COMPANY_NAME = result.RSP.DATA.COMPANY_NAME;
          this.ATTN_CERT_ADDR = result.RSP.DATA.ATTN_CERT_ADDR; 
       this.ATTN_CERT_NUM =  result.RSP.DATA.ATTN_CERT_NUM;
           switch(result.RSP.DATA.ATTN_CERT_TYPE){
      case "1":
         this.ATTN_CERT_TYPE = "身份证";  
         break;
      case "2":
         this.ATTN_CERT_TYPE = "军官证";  
         break;
      case "3":
         this.ATTN_CERT_TYPE = "护照";  
         break; 
      case "4":
         this.ATTN_CERT_TYPE = "港澳居民来往内地通行证";  
         break; 
      case "5":
         this.ATTN_CERT_TYPE = "台湾居民来往大陆通行证";  
         break;
      default:
         this.ATTN_CERT_TYPE = "异常";  
      } 
       this.ATTN_NAME =  result.RSP.DATA.ATTN_NAME;
       this.ATTN_PHONE =  result.RSP.DATA.ATTN_PHONE;
       this.COMPANY_CERT_NUM =  result.RSP.DATA.COMPANY_CERT_NUM;
       if(result.RSP.DATA.COMPANY_CERT_TYPE == "1")
       this.COMPANY_CERT_TYPE =  "营业执照";
       this.COMPANY_ID =  result.RSP.DATA.COMPANY_ID;
       this.COMPANY_LOGO_URL =  result.RSP.DATA.COMPANY_LOGO_URL;
       this.COMPANY_NAME =  result.RSP.DATA.COMPANY_NAME;
       this.COMPANY_PIC = result.RSP.DATA.IMG_LIST[0].IMG_BASE64;
       this.ATTN_CERT_PIC = result.RSP.DATA.IMG_LIST[1].IMG_BASE64;
       this. AUTHORIZE_PIC= result.RSP.DATA.IMG_LIST[2].IMG_BASE64;
       this.UNIFIED_ACCT_ID =  result.RSP.DATA.UNIFIED_ACCT_ID;
      switch(result.RSP.DATA.STATE){
      case "1":
         this.STATE_MESSAGE = "待审核";  
         break;
      case "2":
         this.STATE_MESSAGE = "审核通过";  
         break;
          case "3":
         this.STATE_MESSAGE = "驳回";  
         break; 
          default:
             this.STATE_MESSAGE = "异常";  

        }
        }
        if( result.RSP.CODE == 'U'){
        this.STATE = true;
        this.TAG_MESSAGE = "修改信息";
        }
        else if(result.RSP.CODE == '0001'){
          this.STATE = false;
      }     
 
      wx.hideLoading();
       },
        handleclick(TAG_MESSAGE){
          if(TAG_MESSAGE == "修改信息"){
            this.ACT_TYPE = "U";
          } 
           if(TAG_MESSAGE == "立即认证"){
            this.ACT_TYPE = "A";
          } 
           wx.navigateTo(
          {
            url: '../uploadone/main?info='+ this.ACT_TYPE
          })
    },
    loginout() {
      wx.removeStorageSync('info');
      wx.navigateTo(
          {
            url: '../register/main'
          })
    },
    bindViewTap () {
      const url = '../logs/main'
      if (mpvuePlatform === 'wx') {
        mpvue.switchTab({ url })
      } else {
        mpvue.navigateTo({ url })
      }
    },
    clickHandle (ev) {
      console.log('clickHandle:', ev)
      // throw {message: 'custom test'}
    }
    
    
  },
   onLoad:function(options) {
    let that = this;
     //that.infomation = JSON.parse(wx.getStorageSync('info'));
     that.infomation = wx.getStorageSync('info');//获取登录接口返回信息
    if(that.infomation == ""){
    wx.navigateTo(
          {
            url: '../register/main'
          })
      }
      else{
          that.infomation = JSON.parse(that.infomation);
          this.PHONE = that.infomation.PHONE;
          this.UNIFIED_ACCT_ID = that.infomation.UNIFIED_ACCT_ID;
          this.UNIFIED_ACCT_NUMBER = that.infomation.UNIFIED_ACCT_NUMBER;
          this.queryCompanyInfo();
     }
      },

  created () {
    
  }
}
</script>

<style lang="scss" scoped>
.img{
    width: 100%;
    height: 150px;
  }
  .main{
    font-size: 20px;
        background-color: #ededed;
    p{
      font-size: 30px;
    }
  }
  .info-box{
    border:1px solid #000;
    border-radius: 8px;
    margin:10px 10px 30px 10px ;
    padding:10px;
  }
  .line{
    line-height:3em;

  }
  .title{
    position:relative;
    top:1.2em;
    left:1em;
    font-size:20px !important;;
    width:4.5em;
    background-color:#fff;
  }
  .weui-label{
    display: block;
    width: 6.5em;
    word-wrap: break-word;
    word-break: break-all;
  }
  .weui-btn_primary{
      background-color: #07C160;
      display: inline-block;
    width: auto;
    padding:  0.5em;
    line-height:2em;
    font-size: 14px;
    color:#fff;
    border-radius:0.5em;
  }
  .head {
  img {
    width: 100%;
    height: 100px;
  }
}
.weui-cell__hd{
  font-weight: 600;

}
.overinput{
  display: block;
    overflow: hidden;
    word-break: normal;
    word-wrap: break-word
}
.weui-cells_form{
margin-bottom: 20px;
}
  
</style>
